using System;
using System.Collections.Generic;
using System.IO;

namespace DoItNow
{
	public struct SearchEntry
	{
		public string Name;
		public string Description;
		public object Tag;

		public SearchEntry(string name, string description, object tag)
		{
			Name = name;
			Description = description;
			Tag = tag;
		}

		public static List<SearchEntry> CreateSearchEntries(List<string> paths)
		{
			var entries = new Dictionary<string, SearchEntry>();

			foreach (string path in paths)
			{
				if (entries.ContainsKey(path))
					continue;

				entries.Add(path, new SearchEntry(Path.GetFileName(path), Path.GetDirectoryName(path), path));
			}

			var uniqueEntries = new List<SearchEntry>(entries.Values);

			uniqueEntries.Sort(new Comparison<SearchEntry>((lhs, rhs) => String.Compare(lhs.Name, rhs.Name)));

			return uniqueEntries;
		}
	}
}